﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Templates_Download_Download : BaseTemplateUserControl
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void DataBind(bool raiseOnDataBinding)
    {
        base.DataBind(raiseOnDataBinding);
        Acms.Bll.PostControl control = AcmsContext.CurrentPost.FindPostControl("Download");
        if (control != null)
        {
            Acms.AcmsControls.DownloadableFileContentControlProperties prop = control.GetProperties<Acms.AcmsControls.DownloadableFileContentControlProperties>();
            if (prop != null)
            {
                switch (prop.FileType)
                {
                    case Acms.Bll.File.FileTypes.Pdf:
                        lnk.ImageUrl = "~/Templates/images/pdfIco.gif";
                        break;
                    case Acms.Bll.File.FileTypes.Excel:
                        lnk.ImageUrl = "~/Templates/images/xlsIco.gif";
                        break;
                    case Acms.Bll.File.FileTypes.PowerPoint:
                        lnk.ImageUrl = "~/Templates/images/pptIco.gif";
                        break;
                    case Acms.Bll.File.FileTypes.None:
                        if (prop.Extension == "pdf")
                        {
                            lnk.ImageUrl = "~/Templates/images/pdfIco.gif";
                        }
                        else if (prop.Extension == "xls")
                        {
                            lnk.ImageUrl = "~/Templates/images/xlsIco.gif";
                        }
                        break;
                }
            }
        }
    }
}
